package com.badlogic.androidgames.framework.gl;

public class Animation {

	public static final int ANIMATION_LOOPING = 0;
	public static final int ANIMATION_NONLOOPING = 1;
	
	final TextureRegion[] keyFrames;
	final float frameDuration;
	
	public Animation(float frameDuration, TextureRegion... keyFrames){
		this.frameDuration = frameDuration;
		this.keyFrames = keyFrames;
	}
	
	public TextureRegion getKeyFrame(float stateTime, int mode){
		int frameNumber = (int) (stateTime/frameDuration);
		
		if(mode == ANIMATION_LOOPING)
			frameNumber = frameNumber%keyFrames.length;
		else
			frameNumber = Math.min(frameNumber, keyFrames.length-1);
		return keyFrames[frameNumber];
	}
	
	
}
